<?
        $results = array();
        require_once('../inc/customerPhones.php');
        if(isset($_POST['user_ID']))
        {
                $row = $_POST;
                $results = savePhone($row);
                if($results === true)
                {
               			header("Location: index.php?inserted=".$row['user_ID']."#Inserted");
                        die();
                }
          
        }else{
        	if(isset($_REQUEST['phone']) || isset($_REQUEST['type']))
                $row = $_REQUEST;   
            else
            	$row = blankPhone($_REQUEST['id']);
        }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Details of Phones</title>
    <link rel="stylesheet" type="text/css" href="../inc/bootstrap.css" />
    <style type="text/css">
        .error { color: red; }
    </style>
</head>

<body>
        <div class="container">
            <div id="contents">
               <dl class="error">
                        <? foreach ($results as $key => $value): ?>
                                                <dt><?=$key?></dt>
                                                <dd><?=$value?></dd>
                                        <? endforeach; ?>
                </dl>
               
                <form class="form-horizontal" method="post" action="">
                     <div class=" control-group">
                        <div class="controls">
                       		 <input type="hidden" name="user_ID" value="<?=$row['user_ID']?>" />
                       		 <input type="hidden" name="type" value="<?=$row['type']?>" />
                       		 <input type="hidden" name="phone" value="<?=$row['phone']?>" />
                        </div>
                    </div>
                    <div class=" control-group">
                        <div class="controls">
                        </div>
                    </div>                        
                    <div class=" control-group">
                        <label class="control-label" for="newType">Type:</label>
                        <div class="controls">
                            <input type="text" name="newType" id="newType" value="<?=$row['type']?>" />
                        </div>
                    </div>
                    <div class=" control-group">
                        <label class="control-label" for="newPhone">Phone:</label>
                        <div class="controls">
                            <input type="text" name="newPhone" id="newPhone" value="<?=$row['phone']?>" />
                        </div>
                    </div>
                    <div class=" control-group">
                        <div class="controls">
                        	<input class="btn btn-primary" type="submit" value="Save" />
                  			<a href="./" class="cancel-link">Cancel</a>
                        </div>
                    </div>
                </form>
           </div>
       </div>
</body>
</html>
